<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Subtitle Avisynth Filter</title>
<link rel="stylesheet" type="text/css" href="../../avisynth.css">
</head>
<body>
<h2>Subtitle</h2>
<p><code>Subtitle </code>(<var>clip, string text, int &quot;x&quot;, int &quot;y&quot;,
  int &quot;first_frame&quot;, int &quot;last_frame&quot;, string &quot;font&quot;,
  int &quot;size&quot;, int &quot;text_color&quot;, int &quot;halo_color&quot;, int &quot;align&quot;, int &quot;spc&quot;</var>)<br>
<code>Subtitle </code> (<var>clip, string text</var>)</p>
<p>The <code>Subtitle</code>  filter adds a single line of anti-aliased text to a range of frames. If you want more than one subtitle, or a subtitle that takes more than one line, you have to chain several <code>Subtitle</code>
filters together. This filter is obviously unsuitable for anything more than occasional use. I use it occasionally. All parameters after text are optional and can be omitted or specified out of order using the
<i>name</i>=<i>value</i> syntax.</p>
<p><b>Parameters</b></p>
<p><var>text</var>   is the text which will be overlayed on the clip starting
from frame <var>first_frame</var> and ending with frame <var>last_frame</var>. <var>font</var>
is the fonts of the text (all installed fonts on the current machine are available,
they are located in your 'windows\fonts' folder). <var>size</var> is the size of
the text. (<var>x</var>,<var>y</var>) is the position of the text. The
parameters <var>x</var> and <var>y</var> can be set to -1 to automatically calculate and use the horizontal or vertical center coordinate.
The <var>text_color</var>  and <var>halo_color</var> should be given as hexadecimal RGB values, as in HTML--except that they start with $ instead of #. (I was already using # to introduce a comment.)</p>
<p>The <var>align</var> parameter allows you to set where the text is placed relative to the (x,y) location and is based on the numeric keypad as follows:</p>
<table border="1" width="100%">
  <tr>
    <td width="15%">&lt;left> 7 &lt;top></td>
    <td width="15%"> 	&lt;center> 8 &lt;top></td>
    <td width="15%"> 	&lt;right> 9 &lt;top></td>
    <td width="25%"> 	top of text aligned to y-location for align=7,8,9</td>
  </tr>
  <tr>
    <td width="15%">&lt;left> 4 &lt;baseline></td>
    <td width="15%"> 	&lt;center> 5 &lt;baseline></td>
    <td width="15%"> 	&lt;right> 6 &lt;baseline></td>
    <td width="25%"> 	baseline of text aligned to y-location for align=4,5,6</td>
  </tr>
  <tr>
    <td width="15%">&lt;left> 1 &lt;bottom></td>
    <td width="15%"> 	&lt;center> 2 &lt;bottom></td>
    <td width="15%"> 	&lt;right> 3 &lt;bottom></td>
    <td width="25%"> 	bottom of text aligned to y-location for align=1,2,3</td>
  </tr>
  <tr>
    <td width="15%">start at x for align=1,4,7</td>
    <td width="15%">	center on x for align=2,5,8</td>
    <td width="15%">	end at x for align=3,6,9</td>
    <td width="25%">&nbsp;</td>
  </tr>
</table>
<p>
    Note: There is no Y-center alignment setting.
<p>
    The <var>spc</var> parameter allows you to modify the character spacing (0=unchanged). The value can be positive or negative to widen or narrow the text. Per the Visual C++ documentation of the function that performs this task, this value is in logical units and rounded to the nearest pixel. This is helpful for trying to match typical fonts on the PC to fonts used in film and television credits which are usually wider for the same height or to just fit or fill in a space with a fixed per-character adjustment.
<p>
    The alternate, short form is useful when you don't really care what the subtitle looks like as long as you can see it--for example, when you're using
    <a href="stack.htm"> StackVertical</a> and its ilk to display several versions of a frame at once, and you want to label them to remember which is which.
<p>
    This filter is used internally by AviSynth for the <a href="version.htm"> Version</a> command and for reporting error messages, and the subtitling apparatus is also used by
    <a href="showframes.htm">ShowFrameNumber</a>.
<p>
    <b>Default Values</b>
<table border="1" width="50%">
  <tr>
    <td width="10%"><var>clip</var></td>
    <td width="50%">            last&nbsp;</td>
  </tr>
  <tr>
    <td width="10%"><var>text</var></td>
    <td width="50%">            no default, must be specified&nbsp;</td>
  </tr>
  <tr>
    <td width="10%"><var>x</var></td>
    <td width="50%">            8 if align=1,4,7 or none; -1 if align=2,5,8; or width-8 if align=3,6,9&nbsp;</td>
  </tr>
  <tr>
    <td width="10%"><var>y</var></td>
    <td width="50%">            height-1 if align=1,2,3; size if align=4,5,6 or none;
      or 0 if align=7,8,9</td>
  </tr>
  <tr>
    <td width="10%"><var>first_frame</var></td>
    <td width="50%">            0</td>
  </tr>
  <tr>
    <td width="10%"><var>last_frame</var></td>
    <td width="50%">            framecount(clip)-1</td>
  </tr>
  <tr>
    <td width="10%"><var>font</var></td>
    <td width="50%">            "Arial"</td>
  </tr>
  <tr>
    <td width="10%"><var>size</var></td>
    <td width="50%">18</td>
  </tr>
  <tr>
    <td width="10%"><var>text_color</var></td>
    <td width="50%">            $FFFF00 &lt;yellow></td>
  </tr>
  <tr>
    <td width="10%"><var>halo_color</var></td>
    <td width="50%">            0 &lt;black></td>
  </tr>
  <tr>
    <td width="10%"><var>align</var></td>
    <td width="50%">            Normally 4 &lt;left and baseline>; if x=-1, then 5 &lt;horizontal center and baseline></td>
  </tr>
  <tr>
    <td width="10%"><var>spc</var></td>
    <td width="50%">            0 &lt;font spacing unchanged></td>
  </tr>
</table>
<p>
    <b>Examples</b>
<pre># Some text in the center of the clip
AviSource(&quot;D:\clip.avi&quot;)
Subtitle(&quot;Hello world!&quot;, align=5)</pre>
<pre># Some text in the upper right corner of the clip with specified font, size and color.
AviSource(&quot;D:\clip.avi&quot;)
Subtitle(&quot;Hello world!&quot;, font=&quot;georgia&quot;, size=24, text_color=$ff0000, align=9)</pre>
<p>
    <b>Version Specific Information</b>
<table border="1" width="50%">
  <tr>
    <td width="10%">v1.00</td>
    <td width="50%">Setting x=-1 uses horizontal center and center alignment (undocumented prior to v2.07)</td>
  </tr>
  <tr>
    <td width="10%">v2.07</td>
    <td width="50%">Added align and spc parameters.<br>
        Setting y=-1 calculates vertical center (alignment unaffected)&nbsp;<br>
        Default x and y values dependent on alignment (previously x=8, y=size)&nbsp;</td>
  </tr>
</table>
<p><kbd>$Date: 2005/10/03 16:49:04 $</kbd>
<FORM>
<INPUT TYPE="Button" VALUE="Back"
onClick="history.go(-1)">
</form>
</body>
</html>
